<template>
	<view class="wrap-container">
		<view class="warp-content">
			<view>{{ "人数限制" }}</view>
			<view>
				<uni-easyinput
					focus
					v-model="demandPeopleNumber"
					placeholder="请输入内容">
				</uni-easyinput>
			</view>
			<view>{{ "人" }}</view>
			<button
				@click="saveNum"
				type="primary"
				style="
					margin-top: 5rpx;
					margin-left: 0;
					margin-right: 0;
					font-size: 12px;
					height: 60rpx;
					line-height: 60rpx;
				">
				保存
			</button>
		</view>
		<view class="img">
			<view v-if="loaded">
				<uv-qrcode
					style="margin: auto"
					ref="qrcode"
					canvas-id="qrcode"
					:value="signUrl"
					size="200rpx"
					:loading="loading">
				</uv-qrcode>
				{{ "报名签到二维码" }}
			</view>
			<!-- <view v-if="loaded">
				<uv-qrcode
					style="margin: auto"
					ref="qrcodes"
					canvas-id="qrcodes"
					:value="signUrl"
					size="200rpx"
					:loading="loading">
				</uv-qrcode>
				{{ "打卡二维码" }}
			</view> -->
		</view>
		<view class="btn">
			<button type="primary" @click="goPush">完成需求</button>
		</view>
	</view>
</template>

<script>
import configService from "../../common/service/service";
import api from "../../api/api";
export default {
	props: {
		sendId: {
			default: null,
			type: Object,
		},
	},
	data() {
		return {
			loaded: false,
			demandPeopleNumber: "",
			signUrl: "http://"+window.location.hostname+":"+window.location.port+"/#/pages/component/sign?id=",
			CheckUrl:
				configService.apiUrl + "/jeecg-boot/bmdb/hyPartyRegistration/edit",
			loading: false,
		};
	},
	methods: {
		goPush() {
			uni.navigateTo({
				url: "/pages/component/updateHydynamic?id="+this.sendId.hydynamic.id+'&demandTitle='+this.sendId.hyDemandPage.demandTitle+'&demandContent='+this.sendId.hyDemandPage.demandContent,
			});
		},
		saveNum() {
			var postData = this.sendId.hydynamic;
			var data = {
				deptId: postData.deptId,
				id: postData.id,
				demandPeopleNumber: this.demandPeopleNumber,
			};
			api.edit(data).then((e) => {
				uni.showToast({
					title: e.data.message,
					icon: "success",
					duration: 1000,
				});
			});
		},
	},
	mounted() {
		this.demandPeopleNumber = this.sendId.hydynamic.demandPeopleNumber;
		this.signUrl += this.sendId.hydynamic.id;
		this.loaded = true;
	},
};
</script>

<style lang="scss" scoped>
.warp-content {
	display: flex;
	justify-content: space-around;
	margin: 10px auto;
	height: 40px;
	line-height: 40px;
	::v-deep.uni-easyinput__content {
		width: 100%;
	}
}
.btn {
	margin: 20px auto;
	width: 50%;
}
.img {
	margin-top: 20px;
	display: flex;
	justify-content: space-around;
	text-align: center;
}
</style>
